import fetch from 'common/src/utils/fetch';
/**
 *
 * 获取占用教室
 * @param calendarId 学期Id
 * @param condition  占用时段条件数组 形如
 * [{dayOfWeek:1, startTime:2, endTime:3, weeks:[1,3,5,7]}] weeks可以为空默认为全部
 */
// function getOccupiedClassroomIds(calendarId, condition) {
//   return fetch({
//     url: `/api/arrangementservice/arrangeOccupy/classroom/${calendarId}`,
//     method: 'post',
//     data: condition
//   })
// }
/**
 *
 * 获取占用教室
 * @param calendarId 学期Id
 * @param arranges  占用时段条件数组 形如
 * [{dayOfWeek:1, startTime:2, endTime:3, weeks:[1,3,5,7]}] weeks可以为空默认为全部
 */
function getOccupiedClassroomIds(calendarId, arranges) {
  // return fetch({
  //   url: `/api/arrangementservice/arrangeOccupy/classroom/${calendarId}`,
  //   method: 'post',
  //   data: arranges
  // })
  //拼接参数
  let param = {}
  param.calendarId = calendarId;
  param.arranges = arranges;
  return getOccupiedClassroomIds2(param);
}

function getOccupiedClassroomIds2(param) {
  return fetch({
    url: `/api/baseresservice/occupations/classroom/conflictIds`,
    method: 'post',
    data: param
  })
}

/**
 *
 * 获取占用教师code
 * @param calendarId 学期Id
 * @param condition  占用时段条件数组 形如
 * [{dayOfWeek:1, startTime:2, endTime:3, weeks:[1,3,5,7]}] weeks可以为空默认为全部
 */
function getOccupiedTeacherCodes(calendarId, condition) {
  return fetch({
    url: `/api/arrangementservice/arrangeOccupy/teacher/${calendarId}`,
    method: 'post',
    data: condition
  })
}

export default {
  getOccupiedClassroomIds,
  getOccupiedTeacherCodes
};
